package com.Aspect;

import com.generator.controller.HandleController;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: htj
 * @Date: 2021/10/5 0005 下午 22:57
 */
@Slf4j
@Aspect
@Component
public class MyAspect {

    //切入点
    @Pointcut("execution(* com.util.MockService.service(..))")
    public void checkRequest() {
    }

    //环绕通知
    @Around("checkRequest()")
    public Object check(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        long begin = System.currentTimeMillis();
        Object object = proceedingJoinPoint.proceed();//执行方法
        long time = System.currentTimeMillis() - begin;
        log.info("本次模拟服务处理时间为{}ms", Long.toString(time));
        return object;
    }
}
